#!/usr/bin/perl -w
use strict;
my $fh1;
my $fh2;
my $readname;
my $out;

#open $fh1,"/home/aaithal/indel/manual/out.r1.fq" or die "could not open $_";
open $fh1,$ARGV[0] or die "could not open $_";
open $fh2,$ARGV[1] or die "could not open $_";
open ($out,">".$ARGV[2]) or die "could not open $_";
my $line_f1;
my $line_f2;
my $counter = 0;

while (($line_f1 = <$fh1>)&&($line_f2 = <$fh2>)){
	my $temp;
	
	my $read_name = $line_f1;
	chomp($read_name);

	$read_name =~ s/(.*)(\/[0-9])/$1/;
	$temp = $read_name."\t";

	$line_f1 = <$fh1>;
	my $seq_data = $line_f1;
	chomp($seq_data);
	$temp .= $seq_data."\t";

	$line_f1 = <$fh1>;
	$line_f1 = <$fh1>;
	my $q_data = $line_f1;
	chomp($q_data);
	$temp .= $q_data."\t";

	$line_f2 = <$fh2>;
	$seq_data = $line_f2;		
	chomp($seq_data);
	$temp .= $seq_data."\t";

	$line_f2 = <$fh2>;
	$line_f2 = <$fh2>;
	$q_data = $line_f2;
	chomp($q_data);
	$temp .= $q_data."\n";

	print $out $temp;	

}

print "\n$counter\n";
close $out;
close $fh2;
close $fh1;

